package xidian.vlab.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xidian.vlab.dto.FormDTO;
import xidian.vlab.dto.MsgDTO;
import xidian.vlab.dto.QueryDTO;
import xidian.vlab.dto.ResJsonDTO;
import xidian.vlab.service.RecordService;
import xidian.vlab.utils.ResUtil;

@RestController
@RequestMapping("/record")
public class RecordController {
    @Autowired
    private RecordService recordService;


    @PostMapping("/submit")
    public ResJsonDTO submitRecord(@RequestBody MsgDTO msg){
        if (msg == null) return ResUtil.ERROR("未提供表单");
        return recordService.store(msg);
    }
    @GetMapping("/list")
    public ResJsonDTO getList(QueryDTO query){
        if (query == null) return ResUtil.ERROR("未提供参数");
        return recordService.getList(query);
    }
    @GetMapping("/number")
    public ResJsonDTO getNum(){
        return recordService.getNum();
    }
    @PostMapping("/update")
    public ResJsonDTO updateRecord(@RequestBody QueryDTO query){
        if (query == null) return ResUtil.ERROR("未提供参数");
        return recordService.updateRecord(query);
    }
}
